import { decryptWS } from "./decrypter.js";
import { printBuffer } from "./print.js";

// 从wireshark复制字节数据
const input = `
0000   50 98 b8 7d f2 4f 58 11 22 ae 6e cf 08 00 45 00
0010   00 54 f4 05 40 00 80 06 00 00 c0 a8 08 0f c0 a8
0020   01 4b da 1f 1f 41 49 89 b1 24 4a 9b 6d bf 50 18
0030   20 05 8a f1 00 00 82 a6 f9 2e 35 27 f9 8d 35 27
0040   f9 2e 35 27 f9 2e 35 27 f8 07 35 27 dc cb 35 27
0050   f9 2e 35 27 f9 22 35 25 f9 2c 35 27 f9 2c 35 27
0060   f9 2d
`;
// 左侧显示的Data (xx bytes)
const bytesSize = 44;

const tokens = input.split(/\s+/).filter((v) => Boolean(v) && v.length == 2);
const dataBytes = tokens.slice(tokens.length - bytesSize);
console.log('raw bytes:', dataBytes.join(' '));

printBuffer(decryptWS(new Uint8Array(dataBytes.map((v) => parseInt(v, 16)))));
